package com.tedu.bill.demo7;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Author：毕龙
 * Date: 2024/5/7 19:39
 */
public class TestLambda2 {
    public static void main(String[] args) {
       int[] arrs = {1,3,8,5,7,2};
       Arrays.sort(arrs);
       System.out.println(Arrays.toString(arrs));
        Student[] students = {
                new Student(1,99),
                new Student(8,59),
                new Student(3,78),
                new Student(9,68),
                new Student(5,88),
                new Student(6,88),
                new Student(4,88)
        };
        Arrays.sort(students, (s1,s2)->{
           if(s1.getScore() < s2.getScore() ){
               return 1;
           }else if(s1.getScore() == s2.getScore() ){
                return  s1.getAge()-s2.getAge();
           }else{
               return -1;
           }
        });
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i]);
        }

    }
}
